// 写一个防抖函数，减少监听每一张图片加载完成，频繁调用refresh函数
export function debounce(func, delay) {
	let timer = null;
	return function (...args) {
		if (timer) clearTimeout(timer)
		timer = setTimeout(() => {
			func.apply(this, args)
		}, delay)
	}
}

// 写一个时间戳转yyyy-MM-dd
export function formatDate(timeStamp) {
	let date = new Date(timeStamp)
	let YY = date.getFullYear() + "-";
	let MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
	let DD = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate())
	// let hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ":"
	// let mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ":"
	// let ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds())
	// return YY + MM + DD + "" + hh + mm + ss
	return YY + MM + DD
}
